﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using weather.cn.com.webxml.www;

namespace weather
{
    class Program
    {
        static void Main(string[] args)
        {
            WeatherWebService myweather = new WeatherWebService();
            string[] myweathers = myweather.getWeatherbyCityName("郑州");

            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("今日天气：\n更新时间:" + myweathers[4]);
            Console.WriteLine("当前选择地区：" + myweathers[0] + "_" + myweathers[1] + "\n");
            Console.ForegroundColor = ConsoleColor.White;

            Console.Write(myweathers[6] + "(今日)  风向&风力：" + myweathers[7]);
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(" 气温：" + myweathers[5] + "\n");
            Console.ForegroundColor = ConsoleColor.White;

            Console.WriteLine("当前实况（数据每2.5小时左右自动更新一次）：\n" + myweathers[10] + myweathers[11]);

            Console.Write(myweathers[13] + "(明天)  风向&风力：" + myweathers[14]);
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(" 气温：" + myweathers[12] + "\n");
            Console.ForegroundColor = ConsoleColor.White;

            Console.Write(myweathers[18] + "(后天)  风向&风力：" + myweathers[19]);
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(" 气温：" + myweathers[17] + "\n");
            Console.ForegroundColor = ConsoleColor.White;

            Console.WriteLine("输入1查询其他城市");

            string shuru = Console.ReadLine();

            while (shuru.Trim() == "1")
            {
                Console.WriteLine("请输入您要的查询其他城市：\n（注意不要带“市”字,县市无法查询时，可以输入归属行政市）");
                string newweather = Console.ReadLine();
                WeatherWebService myweather1 = new WeatherWebService();
                string[] myweathers1 = myweather1.getWeatherbyCityName(newweather);
                if (myweathers1[0].Trim() == "查询结果为空！")
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("输入的查询结果为空，请检查拼写后重新输入！");
                    Console.ForegroundColor = ConsoleColor.White;
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("今日天气：\n更新时间:" + myweathers1[4]);
                    Console.WriteLine("当前选择地区：" + myweathers1[0] + "_" + myweathers1[1] + "\n");
                    Console.ForegroundColor = ConsoleColor.White;

                    Console.Write(myweathers1[6] + "(今日)  风向&风力：" + myweathers1[7]);
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(" 气温：" + myweathers1[5] + "\n");
                    Console.ForegroundColor = ConsoleColor.White;

                    Console.WriteLine("当前实况（数据每2.5小时左右自动更新一次）：\n" + myweathers1[10] + myweathers1[11]);

                    Console.Write(myweathers1[13] + "(明天)  风向&风力：" + myweathers1[14]);
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(" 气温：" + myweathers1[12] + "\n");
                    Console.ForegroundColor = ConsoleColor.White;

                    Console.Write(myweathers1[18] + "(明天)  风向&风力：" + myweathers1[19]);
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(" 气温：" + myweathers1[17] + "\n");
                    Console.ForegroundColor = ConsoleColor.White;
                }

                Console.WriteLine("输入1查询其他城市");
                shuru = Console.ReadLine();

            }
        }
    }
}
